package main

import (
	"fmt"
)

func writedata(stringchan chan string) {
	for i := 1; i <= 10; i++ {
		stringchan <- "张三"
		stringchan <- "李四"
		stringchan <- "王五"
		stringchan <- "赵六"
	}
	close(stringchan)
}

func readdata(stringchan chan string, exitchan chan bool) {
	for {
		v, ok := <-stringchan
		if !ok {
			break
		}
		fmt.Println(v)

	}
	exitchan <- true
	close(exitchan)
}

//张三，李四，王五，赵六
func main() {
	stringchan := make(chan string, 40)
	exitchan := make(chan bool, 1)
	go writedata(stringchan)
	go readdata(stringchan, exitchan)
	go writedata(stringchan)
	go readdata(stringchan, exitchan)
	for {
		_, ok := <-exitchan
		if !ok {
			break
		}
	}

}
